package com.sgb.member.ui.adapter;

import android.app.Activity;

import com.bumptech.glide.Glide;
import com.bumptech.glide.load.resource.bitmap.RoundedCorners;
import com.bumptech.glide.request.RequestOptions;
import com.sgb.member.BR;
import com.sgb.member.R;
import com.sgb.member.databinding.ItemOtherLogistics3Binding;
import com.sgb.member.databinding.ItemOtherLogisticsBinding;
import com.sgb.member.entity.CarManageBean;
import com.sgb.member.entity.MemberLogisticsEntity;
import com.sgb.member.weight.MemberCallback;
import com.swgk.core.recyclerview.adapter.BaseRecycleAdapter;
import com.swgk.core.recyclerview.adapter.ItemViewHolder;

import java.util.List;

/**
 * 物流货运-会员货运
 * @param <T>
 */
public class WuLiuMemberAdapter3<T> extends BaseRecycleAdapter<T> {

    MemberCallback memberCallback;

    public WuLiuMemberAdapter3(Activity activity, int layoutId, List<T> datas) {
        super(activity, layoutId, datas);
    }

    public WuLiuMemberAdapter3(Activity activity, int layoutId, List<T> datas, MemberCallback memberCallback) {
        super(activity, layoutId, datas);
        this.memberCallback = memberCallback;
    }

    @Override
    public void convert(ItemViewHolder holder, final T t) {
        logisticsGoods(holder, t);
    }

    private IChildClick<T> iChildClick;

    public void onIChildClick(IChildClick<T> iChildClick) {
        this.iChildClick = iChildClick;
    }

    public interface IChildClick<T> {
        void onClick(T tenderListEntity);
    }

    // 物流货物 -会员货运
    private void logisticsGoods(ItemViewHolder holder, T t) {
        holder.setBinding(BR.viewModel, t);
        CarManageBean entity = (CarManageBean) t;
        ItemOtherLogistics3Binding binding = (ItemOtherLogistics3Binding) holder.getmBinding();
        binding.tvCarNum.setText(entity.getCarNumber()+" "+entity.getContrcts());
        binding.tvType.setText(entity.getCarLenName()
                +"/"+entity.getCarTypeName()
                +"/"+entity.getWeight()+"吨");
        binding.tvCompany.setText(entity.getProvinceName()
                +entity.getCityName()+entity.getDistrictName());
        RoundedCorners roundedCorners= new RoundedCorners(10);
//通过RequestOptions扩展功能,override:采样率,因为ImageView就这么大,可以压缩图片,降低内存消耗
        RequestOptions options=RequestOptions.bitmapTransform(roundedCorners);
        Glide.with(context).load(entity.getCarImage()).apply(options)
                .error(R.drawable.vehicle_detail_paceholder).into(binding.img);
    }




}
